package com.yang.thread.state;

/**
 * @author yds
 * @program thread-study
 * @description 实现线程的join方法 join抢占线程，其余线程均阻塞
 * @create 2020-09-23 14:45
 **/
public class ThreadJoin implements Runnable{

    @Override
    public void run() {
        for (int i = 0; i < 5; i++) {
            System.out.println(Thread.currentThread().getName()+"--->Vip 抢占位置"+i);
        }
    }

    public static void main(String[] args) throws InterruptedException {
        ThreadJoin t1=new ThreadJoin();
        Thread tt1=new Thread(t1,"会员a");
        tt1.start();
        for (int i = 0; i < 10; i++) {
            System.out.println(Thread.currentThread().getName()+i+"抢占票数");
            if(i==5){
                tt1.join();
            }
        }
    }
}